package taskman;

import java.util.Date;


/*
 * COMP 354 Project - Team 6
 */
public class Task
{
	/*
	 * The date on which this task is suppose to start
	 */
	private Date startDate;
	
	/*
	 *The date on which this task is suppose to end.
	 */
	private Date deadline;
	
	/*
	 * The number of days since the start date that has elapsed
	 */
	private int numberOfDaysElapsed;
	
	/*
	 * The percentage complete. 
	 */
	private int percentageComplete;
	
	/*
	 * The parentID represent the id of the parent task when
	 * If there is no parent task, this variable will remain null.
	 */
	private String  parentTaskId;
	
	/*
	 * The id of this task
	 */
	private String	id;
	
	/*
	 * The title of this task
	 */
	private String	title;
	
	/*
	 * A short description of what this task is about
	 */
	private String	description;
	
	/*
	 * The duration of this task in terms of days
	 */
	private double	duration;
	
	/*
	 *The deliverables for this task 
	 */
	private String	deliverable;
	
	/*
	 * The id of the person to whom this task is assigned
	 */
	private String	personId;

	/**
	 * Constructor to be used when creating a task that has a parent task.
	 * When a task has a parent task, it will be referred as a subtask.
	 * @param parentTaskId The id of the parent task
	 * @param id The id of this task
	 * @param title The title of this task
	 * @param description A short description of what this task is about
	 * @param duration The duration of this task in terms of hours
	 * @param deliverable The description of any deliverables.
	 * @param deadline The dealing
	 * @param person The name of the person assigned to this task
	 */
	public Task(String parentTaskId, String id, String title, String description, double duration,
			String deliverable, Date deadline, String person, Date startDate, int percentComplete, int numberOfDaysElapsed)
	{
		this.id = id;
		this.title = title;
		this.description = description;
		this.duration = duration;
		this.deliverable = deliverable;
		this.deadline = deadline;
		this.personId = person;
		this.parentTaskId = parentTaskId;
		this.startDate = startDate;
		this.percentageComplete = percentComplete;
		this.numberOfDaysElapsed = numberOfDaysElapsed;
	}
	
	/**
	 * @param id The id of this task
	 * @param title The title of this task
	 * @param description A short description of what this task is about
	 * @param duration The duration of this task in terms of hours
	 * @param deliverable The description of any deliverables.
	 * @param deadline The dealing
	 * @param person The name of the person assigned to this task
	 */
	public Task(String id, String title, String description, double duration,
			String deliverable, Date deadline, String person)
	{
		this.id = id;
		this.title = title;
		this.description = description;
		this.duration = duration;
		this.deliverable = deliverable;
		this.deadline = deadline;
		this.personId = person;
		this.parentTaskId = null;
	}

	/**
	 * 
	 */
	public Task()
	{

	}
	
	public int getNumberOfDaysElapsed()
	{
		return numberOfDaysElapsed;
	}
	
	public void setNumberOfDaysElapsed(int numberOfDaysElapsed)
	{
		this.numberOfDaysElapsed = numberOfDaysElapsed;
	}
	
	public int getPercentageComplete()
	{
		return percentageComplete;
	}
	
	public void setPercentageComplete(int percentageComplete)
	{
		this.percentageComplete = percentageComplete;
	}
	
	public Date getStartDate()
	{
		return startDate;
	}
	
	public void setStartDate(Date startDate)
	{
		this.startDate = startDate;
	}
	
	/**
	 * 
	 * @return
	 */
	public String getParentTaskId()
	{
		return parentTaskId;
	}
	
	/**
	 * 
	 * @param parentTaskId
	 */
	public void setParentTaskId(String parentTaskId)
	{
		this.parentTaskId = parentTaskId;
	}

	/**
	 * 
	 * @return
	 */
	public String getId()
	{
		return id;
	}

	/**
	 * 
	 * @param id
	 */
	public void setId(String id)
	{
		this.id = id;
	}

	/**
	 * 
	 * @return
	 */
	public String getTitle()
	{
		return title;
	}

	/**
	 * 
	 * @param title
	 */
	public void setTitle(String title)
	{
		this.title = title;
	}

	/**
	 * 
	 * @return
	 */
	public String getDescription()
	{
		return description;
	}

	/**
	 * 
	 * @param description
	 */
	public void setDescription(String description)
	{
		this.description = description;
	}

	/**
	 * 
	 * @return
	 */
	public double getDuration()
	{
		return duration;
	}

	/**
	 * 
	 * @param duration
	 */
	public void setDuration(double duration)
	{
		this.duration = duration;
	}

	/**
	 * 
	 * @return
	 */
	public String getDeliverable()
	{
		return deliverable;
	}

	/**
	 * 
	 * @param deliverable
	 */
	public void setDeliverable(String deliverable)
	{
		this.deliverable = deliverable;
	}

	/**
	 * 
	 * @return
	 */
	public Date getDeadline()
	{
		return deadline;
	}

	/**
	 * 
	 * @param deadline
	 */
	public void setDeadline(Date deadline)
	{
		this.deadline = deadline;
	}

	/**
	 * 
	 * @return
	 */
	public String getPersonId()
	{
		return personId;
	}

	/**
	 * 
	 * @param personId
	 */
	public void setPersonId(String personId)
	{
		this.personId = personId;
	}

	/**
	 * 
	 */
	public String toString()
	{
		return this.title + ": " + this.description + "\n Assigned to: "
				+ this.personId;
	}

	@Override
	public boolean equals(Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Task other = (Task) obj;
		if (deadline == null)
		{
			if (other.deadline != null)
				return false;
		}
		else if (!deadline.equals(other.deadline))
			return false;
		if (deliverable == null)
		{
			if (other.deliverable != null)
				return false;
		}
		else if (!deliverable.equals(other.deliverable))
			return false;
		if (description == null)
		{
			if (other.description != null)
				return false;
		}
		else if (!description.equals(other.description))
			return false;
		if (Double.doubleToLongBits(duration) != Double
				.doubleToLongBits(other.duration))
			return false;
		if (id == null)
		{
			if (other.id != null)
				return false;
		}
		else if (!id.equals(other.id))
			return false;
		if (personId == null)
		{
			if (other.personId != null)
				return false;
		}
		else if (!personId.equals(other.personId))
			return false;
		if (title == null)
		{
			if (other.title != null)
				return false;
		}
		else if (!title.equals(other.title))
			return false;
		return true;
	}
}
